{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0b5b071c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "def main(arg1: list) -> list:\n",
    "    out = []\n",
    "    for i in arg1:\n",
    "        json_object = json.loads(i)\n",
    "        url = json_object.get(\"url\", \"\")\n",
    "        out.append(url)\n",
    "        return out\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a8e5db61",
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data = [\n",
    "    {\n",
    "        \"url\": \"https://www.w3cschool.cn/vscode/list\",\n",
    "        \"scrape_id\": \"511b68c9-cc98-4217-a598-b518a4594dc5\",\n",
    "    },\n",
    "    {\n",
    "        \"url\": \"https://www.w3cschool.cn/vscode/vscode-keyboard.html\",\n",
    "        \"scrape_id\": \"511b68c9-cc98-4217-a598-b518a4594dc5\",\n",
    "    },\n",
    "    {\n",
    "        \"url\": \"https://www.w3cschool.cn/vscode/vscode-zwav3p3l.html\",\n",
    "        \"scrape_id\": \"511b68c9-cc98-4217-a598-b518a4594dc5\",\n",
    "    },\n",
    "    {\n",
    "        \"url\": \"https://www.w3cschool.cn/vscode/vscode-intro.html\",\n",
    "        \"scrape_id\": \"511b68c9-cc98-4217-a598-b518a4594dc5\",\n",
    "    }\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2f8d607e",
   "metadata": {},
   "outputs": [],
   "source": [
    "main(test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3c1d92e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n",
      "[{'name': '小明', 'age': 11}, {'name': '小红', 'age': 15}, {'name': '小玉', 'age': 17}]\n",
      "<class 'dict'>\n",
      "{'name': '小菲', 'address': '北京'}\n"
     ]
    }
   ],
   "source": [
    "# 导入JSON模块\n",
    "import json\n",
    "\n",
    "# 通过 json.loads(data)方法把json数据转化为了 python数据\n",
    "s1 = '[{\"name\":\"小明\",\"age\":11},{\"name\":\"小红\",\"age\":15},{\"name\":\"小玉\",\"age\":17}]'\n",
    "l1 = json.loads(s1)\n",
    "print(type(l1))\n",
    "print(l1)\n",
    "\n",
    "s2 = '{\"name\":\"小菲\",\"address\":\"北京\"}'\n",
    "l2 = json.loads(s2)\n",
    "print(type(l2))\n",
    "print(l2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "245831a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "def main(arg1: dict) -> str:\n",
    "    Prompt = arg1.get(\"Prompt\", \"\")\n",
    "    Negative = arg1.get(\"Negative\", \"\")\n",
    "    return Prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d8a2358c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "93bc086e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': 'Prompta young girl swimming in a pool, clear blue water, bright sunlight, vibrant colors, detailed facial features, realistic skin texture, dynamic pose, summer atmosphere, high resolution, photorealistic style'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test = {\"Prompt\":\"a young girl swimming in a pool, clear blue water, bright sunlight, vibrant colors, detailed facial features, realistic skin texture, dynamic pose, summer atmosphere, high resolution, photorealistic style\",\"Negative\":\"blurry, low resolution, distorted face, extra limbs, unnatural lighting, dull colors, unrealistic proportions, water distortion, dark shadows, poor quality\"}\n",
    "main(test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a1999b04",
   "metadata": {},
   "outputs": [],
   "source": [
    "def main(arg1:dict) -> dict:\n",
    "    return {\n",
    "        \"result\": \"Prompt\" + arg1.get(\"Prompt\", \"\"),\n",
    "    }"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
